<template>
    <el-descriptions class="margin-top" style="padding: 20px" title="本机信息" :column="1"  border>
        <el-descriptions-item>
            <template slot="label">
                <i class="el-icon-mobile-phone"></i>
                主机名
            </template>
            <span>{{ systemInfo.hostname }}</span>
        </el-descriptions-item>
        <el-descriptions-item>
            <template slot="label">
                <i class="el-icon-location-outline"></i>
                内存
            </template>
            <span>{{ systemInfo.memory }}</span>
        </el-descriptions-item>
        <el-descriptions-item>
            <template slot="label">
                <i class="el-icon-user"></i>
                操作系统
            </template>
            <span>{{ systemInfo.version }}</span>
        </el-descriptions-item>
        <el-descriptions-item>
            <template slot="label">
                <i class="el-icon-tickets"></i>
                release
            </template>
            <span>{{ systemInfo.release }}</span>
        </el-descriptions-item>
        <el-descriptions-item>
            <template slot="label">
                <i class="el-icon-office-building"></i>
                CPU类型
            </template>
            <span v-if="systemInfo.cpu">{{ systemInfo.cpu[0].model }}</span>
        </el-descriptions-item>
        <el-descriptions-item>
            <template slot="label">
                <i class="el-icon-office-building"></i>
                CPU架构
            </template>
            <span>{{ systemInfo.arch }}</span>
        </el-descriptions-item>
        <el-descriptions-item>
            <template slot="label">
                <i class="el-icon-office-building"></i>
                CPU核数
            </template>
            <span v-if="systemInfo.cpu">{{ systemInfo.cpu.length }}核</span>
        </el-descriptions-item>
        <el-descriptions-item>
            <template slot="label">
                <i class="el-icon-office-building"></i>
                磁盘容量
            </template>
            <span v-if="systemInfo.cpu">{{ diskInfo.total }}</span>
        </el-descriptions-item>
    </el-descriptions>
</template>

<script>
    import { ipcRenderer } from "electron";
    export default {
        components: {},
        created() {
            ipcRenderer.invoke("getSystemInfo").then(res => {
                console.log(res)
                this.systemInfo = res;
            });
            ipcRenderer.invoke("getDiskinfo").then(res => {
                console.log(res)
                this.diskInfo = res;
            });
        },
        data() {
            return {
                form: {
                    name: "",
                    region: "",
                    date1: "",
                    date2: "",
                    delivery: false,
                    type: [],
                    resource: "",
                    desc: ""
                },
                systemInfo: {},
                diskInfo: {}
            };
        },
        methods: {
            onSubmit() {
                console.log(this.form)
                this.$message("submit!");
            },
            onCancel() {
                this.$message({
                    message: "cancel!",
                    type: "warning"
                });
            }
        }
    };
</script>

<style scoped>
    .line {
        text-align: center;
    }
</style>
